package com.zzsy.carosshopprojects.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.king.base.adapter.ViewHolderRecyclerAdapter;
import com.king.base.adapter.holder.ViewHolder;
import com.yatoooon.screenadaptation.ScreenAdapterTools;
import com.zzsy.carosshopprojects.R;
import com.zzsy.carosshopprojects.bean.OrderBean;
import com.zzsy.carosshopprojects.util.AlgorithmUtil;
import com.zzsy.carosshopprojects.util.FormatTimeUtil;
import com.zzsy.carosshopprojects.util.StringUtils;

import java.util.List;

public class OrderAmountAdapter extends ViewHolderRecyclerAdapter<OrderBean.OrdersBean> {


    public OrderAmountAdapter(Context context, List<OrderBean.OrdersBean> listData, int layoutId) {
        super(context, listData, layoutId);
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.adapter_orderamount, null);
        ScreenAdapterTools.getInstance().loadView(view);
        return view;
    }

    @Override
    public void bindViewDatas(ViewHolder helper, OrderBean.OrdersBean bean, int positions) {
        helper.setText(R.id.tv_ordernum, bean.getOrderNumber());
        helper.setText(R.id.tv_money, "￥" + AlgorithmUtil.getAmount(bean.getOrderAmount(), 100));
        helper.setText(R.id.tv_oils, bean.getOilNum());
        String orderCreateTime = bean.getOrderCreateTime();
        if (!StringUtils.isEmpty(orderCreateTime)) {
            helper.setText(R.id.tv_order_time, FormatTimeUtil.formatTimeStamp2DateStr(String.valueOf(Long.parseLong(orderCreateTime) / 1000), "yyyy-MM-dd HH:mm:ss"));
        }
        String payType = bean.getPayType();
        String type = "";
        if (!StringUtils.isEmpty(payType)) {
            if ("1".equals(payType)) {
                type = "支付宝支付";
            } else if ("2".equals(payType)) {
                type = "微信支付";
            } else if ("3".equals(payType)) {
                type = "银联支付";
            } else if ("4".equals(payType)) {
                type = "余额支付";
            }
            helper.setText(R.id.tv_pay_type, type);
        }

    }


}
